#include<bits/stdc++.h>
#define pii pair<int,int>
using namespace std;
inline void read(int& x){
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()){if(ch=='-')f=-1;}
    for(;isdigit(ch);ch=getchar()){x=(x<<3)+(x<<1);x+=(int)ch-'0';}x*=f;
}
bool special1=true;
bool special2=true;
bool special3=true;
const double eps=1e-8;
const int N=1e5+5;
int T;
int n,m,L,V;
struct node{
    int d,v,a;
}c[N];
int p[N];
int plef,prig;
int ans1,ans2;
void init(){
    special1=true;
    special2=true;
    special3=true;
    plef=1e9;
    ans2=0;
    // sum=0;
    prig=0;
}

int dcmp(double a,double b){
    if(fabs(a-b)<=eps)return 0;
    else if(a>b)return 1;
    else return -1;
}

void work1(){
    int lef=1e9,rig=0,sum=0;
    for(int i=1;i<=n;i++){
        if(c[i].v>V&&c[i].d<=prig){
            lef=min(lef,c[i].d);
            rig=max(rig,c[i].d);
            sum++;
        }
    }
    if(lef==1e9){
        cout<<0<<' '<<m<<endl;
        return ;
    }
    int tot=0;

    // for(int i=1;i<=m;i++){
    //     if(p[i+1]<lef&&i+1<=m){
    //         tot++;
    //     }
    // }
    // for(int i=m;i>=1;i--){
    //     if(p[i-1]>rig&&i-1>=1){
    //         tot++;
    //     }
    // }
    cout<<sum<<' '<<m-1<<endl;
}

void work2(){
    int hs[1000005];
    int sum=0;
    for(int i=1;i<=n;i++){
        if(c[i].d>prig)continue;
        if(c[i].v>V&&c[i].d<=prig){
            sum++;
            continue;
        }
        if(dcmp((double)sqrt(c[i].v*c[i].v+2*c[i].a*(prig-c[i].d)),(double)V)>0)
            sum++;
    }
    cout<<sum<<' '<<m-1<<endl;
}

void work3(){
    priority_queue<pii,vector<pii>,greater<pii> > q;
    int sum=0;
    int now=0;
    int pre[1000005];
    for(int i=0;i<=L;i++){
        if(p[now]<i)now++;
        pre[i]=now;
    }
    p[m+1]=1e9;
    for(int i=1;i<=n;i++){
        if(c[i].v<=V)continue;
        if(c[i].d>prig)continue;
        int l=c[i].d;
        int r=c[i].d+(V*V-c[i].v*c[i].v)/(2*c[i].a);
        if(r<plef)continue;

        if(pre[l]==pre[r]&&r<p[pre[r]]){
            continue;
        }
        // cout<<l<<' '<<r<<"l and r"<<endl;
        q.push(make_pair(r,l));
        sum++;
    }
    // cout<<plef<<"plef"<<endl;
    cout<<sum<<' ';
    now=0;
    int mst=0;
    while(now+1<=m){
        now++;
        // cout<<now<<endl;
        if(q.empty())break;
        if(p[now]<q.top().second)continue;
        int y=q.top().first;
        // if(q.top().first==q.top().second){
        //     // cout<<"check"<<endl;
        //     if(p[now]==y){
        //         mst++;
        //         while(q.top().second<=p[now]&&!q.empty())q.pop();
        //         continue;
        //     }
            
        // }
        if(p[now]<=y&&p[now+1]>y){
            mst++;
            while(q.top().second<=p[now]&&!q.empty())q.pop();
        }
        // now++;
    }
    cout<<m-mst<<endl;
}

bool f[N];
int lef[N],rig[N];
int sum;
void dfs(int dep){
    if(dep>m){
        for(int i=1;i<=n;i++){
            bool check=false;
            for(int j=1;j<=m;j++){
                if(lef[i]<=p[j]&&rig[i]>=p[j]&&f[j]){
                    check=true;
                }
            }
            if(check==false){
                return;
            }
        }
        int tot=0;
        for(int i=1;i<=n;i++){
            if(!f[i])tot++;
        }
        ans2=max(ans2,tot);
        return ;
    }
    f[dep]=true;
    dfs(dep+1);
    f[dep]=false;
    dfs(dep+1);
}

void work4(){
    sum=0;
    for(int i=1;i<=n;i++){
        if(c[i].a==0){
            if(c[i].v>V){
                lef[++sum]=c[i].d;
                rig[sum]=prig;
            }
            continue;
        }
        if(c[i].a>0){
            int ls=(V*V-c[i].v*c[i].v)/(2*c[i].a)+c[i].d;
            if(ls<=prig){
                lef[++sum]=ls;
                rig[sum]=prig;
            }
            continue;
        }
        if(c[i].a<0){
            if(c[i].v<=V)continue;
            lef[++sum]=c[i].d;
            rig[sum]=c[i].d+(V*V-c[i].v*c[i].v)/(2*c[i].a);
        }

    }
    dfs(1);
    cout<<sum<<' '<<ans2<<endl;
}

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    read(T);
    while(T--){
        init();
        read(n);read(m);read(L);read(V);
        for(int i=1;i<=n;i++){
            read(c[i].d);read(c[i].v);read(c[i].a);
            if(c[i].a!=0){
                special1=false;
            }
            if(c[i].a<=0){
                special2=false;
            }
            if(c[i].a>=0){
                special3=false;
            }
        }
        for(int i=1;i<=m;i++){
            read(p[i]);
            plef=min(plef,p[i]);
            prig=max(prig,p[i]);
        }
        if(special1){
            work1();
        }
        if(special2){
            work2();
        }
        if(special3){
            // cout<<"??"<<endl;
            work3();
        }
        if(n<=20){
            work4();
        }
        // cout<<"??";
    }
    return 0;
}